#include <allegro.h>
#include "object.h"

object::object(int seconds, int x, int y, int speed_y, BITMAP *img) {
	this->seconds = seconds;
	
	this->x = x;
	this->y = y;

	this->speed_y = speed_y;

	this->img = img;

	this->w = img->w;
	this->h = img->h;
	this->exist = 0;
}

int object::out(int ground_y) {
	if ((y + h) > ground_y)
		return 1;
	return 0;
}

void object::check(int seconds){
	if (this->exist)
		return;
	if (this->seconds < seconds)
		this->exist = 1;
}

void object::move() {
	if (!this->exist)
		return;
	this->y += this->speed_y;
}   
   
void object::draw(BITMAP *buffer) {
	if (!this->exist)
		return;
	draw_sprite(buffer, this->img, this->x, this->y);
}
